package com.lynx.core.impl;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lynx.core.View;
/**
 * 
 * @author lxp
 *
 */
public class JspView implements View {
	private static String VIEW_PATH = "";
	private final String page;

	public JspView(String page) {
		this.page = page;
	}

	public static void setViewPath(String path) {
		if ((VIEW_PATH == null) && (path != null))
			VIEW_PATH = path;
	}

	public String getPage() {
		return this.page;
	}

	public void render(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException,Exception {
		String ret = VIEW_PATH + this.page;
		request.getRequestDispatcher(ret).forward(request, response);
	}
}